package com.gitee.blogcase.simplerabbitmqcase.callback;


import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ReturnedMessage;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

/**
 *  消息投递到队列失败回调处理
 * @author wuwentao
 */
@Slf4j
@Component
public class MessageReturnsCallback  implements RabbitTemplate.ReturnsCallback{
    @Override
    public void returnedMessage(ReturnedMessage returnedMessage) {
        log.info("===================================================");
        log.info("消息投递失败回调函数详细信息如下:");
        log.info("消息内容:{}",new String(returnedMessage.getMessage().getBody()));
        log.info("Exchange:{}",returnedMessage.getExchange());
        log.info("RoutingKey:{}",returnedMessage.getRoutingKey());
        log.info("ReplyCode:{}",returnedMessage.getReplyCode());
        log.info("ReplyText:{}",returnedMessage.getReplyText());
        log.info("===================================================");
    }
}
